import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 绘本内容信息 */
export interface BookContent {
          id: number; // 内容唯一ID
          bookId?: number; // 对应书籍ID
          pages?: string; // 页面内容数组
          creator: string; // 创建者
          createTime: string | Dayjs; // 创建时间
          updater: string; // 更新者
          updateTime: string | Dayjs; // 更新时间
          deleted: boolean; // 是否删除
  }

// 绘本内容 API
export const BookContentApi = {
  // 查询绘本内容分页
  getBookContentPage: async (params: any) => {
    return await request.get({ url: `/pickbook/book-content/page`, params })
  },

  // 查询绘本内容详情
  getBookContent: async (id: number) => {
    return await request.get({ url: `/pickbook/book-content/get?id=` + id })
  },

  // 新增绘本内容
  createBookContent: async (data: BookContent) => {
    return await request.post({ url: `/pickbook/book-content/create`, data })
  },

  // 修改绘本内容
  updateBookContent: async (data: BookContent) => {
    return await request.put({ url: `/pickbook/book-content/update`, data })
  },

  // 删除绘本内容
  deleteBookContent: async (id: number) => {
    return await request.delete({ url: `/pickbook/book-content/delete?id=` + id })
  },

  /** 批量删除绘本内容 */
  deleteBookContentList: async (ids: number[]) => {
    return await request.delete({ url: `/pickbook/book-content/delete-list?ids=${ids.join(',')}` })
  },

  // 导出绘本内容 Excel
  exportBookContent: async (params) => {
    return await request.download({ url: `/pickbook/book-content/export-excel`, params })
  }
}